//
//  TKYProgessView.m
//  StationHouseHelper
//
//  Created by apple on 2018/5/6.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYProgessView.h"
@interface TKYProgessView()
@property (nonatomic, strong) TKYSlider *slider;
@end
@implementation TKYProgessView


- (instancetype)initWithFrame:(CGRect)frame titleLabelText:(NSString *)titleLabelTex {
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        [self initWithTitleLabelText:titleLabelTex];
    }
    return self;
}

- (void)initWithTitleLabelText:(NSString *)titleLabelTex {
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidthScale *20, 15, kWidthScale *70, kHeightScale*20)];
    
    titleLabel.text = titleLabelTex;
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:14];
    [titleLabel sizeToFit];
    [self addSubview: titleLabel];
    
    self.progressLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - 60, 15, kWidthScale *50, kHeightScale *20)];
    self.progressLabel.font = [UIFont systemFontOfSize:14];
    self.progressLabel.text = @"0";
    self.progressLabel.textColor = kRGBColor(32, 136, 252, 1);
    [self addSubview:self.progressLabel];

    // 滑动条slidero
    TKYSlider *slider = [[TKYSlider alloc] initWithFrame:CGRectMake(kWidthScale *90,kHeightScale *19, kScreenWidth - kWidthScale *175, kHeightScale *20)];
    slider.minimumValue = 0;// 设置最小值
    slider.maximumValue = 100;// 设置最大值
    slider.value = self.progressValue;// 设置初始值
    // UIImage *image= [self OriginImage:[UIImage imageNamed:@"slide_btn"] scaleToSize:CGSizeMake(35, 35)];
    [slider setThumbImage:[UIImage imageNamed:@"slide_btn"] forState:UIControlStateNormal];
    [slider setThumbImage:[UIImage imageNamed:@"slide_btn"] forState:UIControlStateHighlighted];
    
    slider.continuous = YES;// 放开手值才确定下来
    slider.minimumTrackTintColor = kRGBColor(34, 130, 255, 1); //滑轮左边颜色，如果设置了左边的图片就不会显示
    slider.maximumTrackTintColor = kRGBColor(238, 238, 238, 1); //滑轮右边颜色，如果设置了右边的图片就不会显示
    [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];// 针对值变化添加响应方法
    self.slider = slider;
    [self addSubview:slider];
    
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, self.kx_height, kScreenWidth, 0.5)];
    line.backgroundColor = kUIColorFromRGB(0XE5E5E5, 1);
    [self addSubview:line];
}


- (void)setProgressValue:(CGFloat)progressValue{
    _progressValue = progressValue ;
    self.slider.value = self.progressValue;
    
}
- (void)sliderValueChanged:(UISlider *)slider{
    if (self.sprogressBlock) {
        self.sprogressBlock(slider);
    }
    NSLog(@"%.lf",slider.value);
    NSLog(@"结束的时候");
}




@end
